package com.example.chapter03.button;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.chapter03.R;
import com.example.chapter03.utils.TimeUtils;

public class ButtonEnableActivity extends AppCompatActivity implements View.OnClickListener{

    private TextView tv_time_test;
    private Button btn_test;
    private Button btn_enable_false;
    private Button btn_enable_true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_button_enable);
        tv_time_test = findViewById(R.id.tv_time_test);
        btn_enable_true = findViewById(R.id.btn_enable_true);
        btn_enable_false = findViewById(R.id.btn_enable_false);
        btn_test = findViewById(R.id.btn_test);
        btn_enable_true.setOnClickListener(this);
        btn_enable_false.setOnClickListener(this);
        btn_test.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_enable_true) {
            btn_test.setEnabled(true);
        }else if (view.getId() == R.id.btn_enable_false) {
            btn_test.setEnabled(false);
        }else if (view.getId() == R.id.btn_test) {
            Log.d("日志","onClick: 触发测试按钮");
            tv_time_test.setText(TimeUtils.getNowTime());
        }
    }
}